/*
package com.pearl.security.multiloginreject.demo.config;

import com.pearl.security.multiloginreject.demo.session.memery.PearlSessionInformationExpiredStrategy;
import com.pearl.security.multiloginreject.demo.session.memery.PearlSessionRegistryImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.session.HttpSessionEventPublisher;


*/
/**
 * 配置类：内存模式
 * @author TangDan
 * @version 1.0
 * @since 2023/5/24
 *//*

@Configuration
@EnableMethodSecurity
public class MemorySecurityConfig {

    @Bean
    SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
        http.authorizeHttpRequests(e -> {
            e.anyRequest().authenticated();
        });
        http.formLogin(formLogin -> formLogin.usernameParameter("username"));
*/
/*        // 开启表单登录
        http.formLogin()
                .successHandler(new JsonAuthenticationSuccessHandler()) // 登录成功处理器
                .failureHandler(new JsonAuthenticationFailureHandler());// 登录失败处理器
        // 关闭 CSRF
        // 异常配置
        http.exceptionHandling()
                .accessDeniedHandler(new JsonAccessDeniedHandler()) // 权限不足
                .authenticationEntryPoint(new JsonAuthenticationEntryPoint()); // 认证入口
        // 注销登录
        http.logout()
                .logoutSuccessHandler(new JsonLogoutSuccessHandler()); //  自定义注销成功处理器*//*

        http.csrf(AbstractHttpConfigurer::disable);
        // 会话管理
        // 1. 内存模式
        http.sessionManagement(session -> session
                //       .sessionAuthenticationStrategy(controlStrategy));
                // 并发控制配置
                .sessionConcurrency(sessionCConcurrency -> {
                    sessionCConcurrency
                            .expiredSessionStrategy(new PearlSessionInformationExpiredStrategy());
                })
                //.sessionAuthenticationStrategy(new ExclusiveSessionStrategy()) // 添加自定义认证会话策略
                .maximumSessions(1)); // 用户最大会话数为 1，后面的登陆就会自动踢掉前面的登陆
        //.maxSessionsPreventsLogin(true)); // 当前已登录时，阻止其他登录
        // 2. Redis 模式

        return http.build();
    }

    @Bean
    PearlSessionRegistryImpl sessionRegistry() {
        return new PearlSessionRegistryImpl();
    }

    @Bean
    public HttpSessionEventPublisher httpSessionEventPublisher() {
        return new HttpSessionEventPublisher();
    }

    */
/**
     * 内存存储用户
     *//*

*/
/*    @Bean
    public UserDetailsService userDetailsService() {
*//*
*/
/*        UserDetails userDetails = User.withDefaultPasswordEncoder()
                .username("user")
                .password("123456")
                .roles("USER")
                .build();*//*
*/
/*
        PearlUserDetails userDetails = new PearlUserDetails("user", "$2a$10$K/Y1kttXG9aNHOhjneXVku9kxC36uQjc9d36yQXhHjHRwf/ciGT/a", "123456", "PC", new ArrayList<>(),
                true, true, true, true);// 账号状态这里都直接设置为启用，实际业务可以存在数据库中
        return new InMemoryUserDetailsManager(userDetails);
    }*//*

    @Bean
    public BCryptPasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}
*/
